import requests from '../util/request'





export const reqUserLogin = (data) => requests({
    url: '/user/login',
    data,
    method: 'post'
})
export const reqUserRegister = (data) => requests({
    url: '/user/register',
    data,
    method: 'post'
})
export const reqLoginState = () => requests({
    url: '/user/isLogin',
    method: 'get',
})
export const reqUserLogout = () => requests({
    url: '/user/logout',
    method: 'post',
})




/*******************************************  用户操作相关【管理员】 ************************************************/
export const reqInfoPage = (data) => requests({
    url: '/user/admin/userInfo/page',
    params: data,
    method: 'get',
})
export const reqResetPassword = (id) => requests({
    url: `/user/admin/userInfo/rePassword/${id}`,
    method: 'put',
})
export const reqSetStatus = (id) => requests({
    url: `/user/admin/userInfo/setStatus/${id}`,
    method: 'put',
})
export const reqDelInfo = (id) => requests({
    url: `/user/admin/userInfo/delete/${id}`,
    method: 'delete',
})





















export const reqUserInfo = (userId) => requests({
    url: `/user/get/${userId}`,
    method: 'get',
})
export const reqTeacherList = () => requests({
    url: `/user/get/list/teachers`,
    method: 'get',
})
export const reqStudentInfoPage = (data) => requests({
    url: '/user/userInfo/page',
    params: data,
    method: 'get',
})
export const reqTotalTimeByUserId = (userId) => requests({
    url: '/course/learningTime/' + userId,
    method: 'get',
})





export const reqUpdateName = (name) => requests({
    url: '/user/change/name',
    data: {"name": name},
    method: 'post',
})
export const reqUpdatePhone = (phone) => requests({
    url: '/user/change/phone',
    data: {"phone": phone},
    method: 'post',
})
export const reqUpdateAvatarUrl = (avatarUrl) => requests({
    url: '/user/change/avatarUrl',
    data: {"avatarUrl": avatarUrl},
    method: 'post',
})
export const reqUpdatePassword = (data) => requests({
    url: '/user/change/password',
    data,
    method: 'post',
})
export const reqUpdateEmail = (data) => requests({
    url: `/email/edit/email/`,
    data,
    method: 'post',
})
export const reqEmailCode = (email) => requests({
    // url: '/email/get/code/',
    url: `/email/get/code`,
    params: {email: email},
    method: 'get',
})
export const reqCheckEmail = (data) => requests({
    // url: '/email/get/code/'+email,
    url: `/get/email/check/${data}`,
    method: 'get',
})


export const reqAddUserInfo = (data) => requests({
    url: `/user/add/userInfo`,
    data,
    method: 'post',
})
export const reqUpdateUserInfo = (data) => requests({
    url: `/user/change/userInfo`,
    data,
    method: 'post',
})
export const reqDelUserInfo = (userId) => requests({
    url: `/user/del/userInfo/${userId}`,
    method: 'delete',
})
export const reqDelUserInfoList = (delUserList) => requests({
    url: `/user/del/userInfo/list`,
    data: {idList: delUserList},
    method: 'delete',
})
